// pages/dingdandetail/index.js
const db = wx.cloud.database()
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            id: options.id,
            type:wx.getStorageSync('user').xinwentype
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        db.collection('dingdan').doc(this.data.id).get().then(res => {
            console.log(res);
            this.setData({
                list: res.data.list,
                ma: res.data.list._id.split("", 6),   
                date:res.data.date   ,
                shijiansuan:res.data.shijiansuan
            })
        })
    },
    quxiao() {
        let that = this;
        wx.showModal({
            title: '温馨提示',
            content: '是否取消？',
            confirmText: "是",
            cancelText: "否",
            success(res) {
                if (res.confirm) {
                    wx.showLoading({
                        title: '取消中'
                    })
                    wx.cloud.callFunction({
                        name: "update",
                        data: {
                            action: "quxiaoyuyue",
                            id: that.data.id,
                        }
                    }).then(res => {
                        wx.hideLoading({
                            success: (res) => {},
                        })
                        wx.navigateBack({
                            delta: 1,
                        })

                    })
                } else if (res.cancel) {}
            }
        })
    },




})